package com.imooc.ecommerce.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类, 读取nacos相关的配置项，用于配置监听器
 * @Author: zhangshao
 * @Date: 2023/11/24 17:06
 */
@Configuration
public class GatewayConfig {

	/**
	 * 读取配置的超时时间
	 */
	public static final long DEFAULT_TIMEOUT = 30000;

	/**
	 * nacos服务器地址
	 */
	public static String NACOS_SERVER_ADD;

	/**
	 * 命名空间
	 */
	public static String NACOS_NAMESPACE;

	/**
	 * data—id
	 */
	public static String NACOS_ROUTE_DATA_ID;

	/**
	 * 分组id
	 */
	public static String NACOS_ROUTE_GROUP;

	@Value("${spring.cloud.nacos.discovery.server-addr}")
	public void setNacosServerAdd(String nacosServerAdd){
		NACOS_SERVER_ADD = nacosServerAdd;
	}

	@Value("${spring.cloud.nacos.discovery.namespace}")
	public void setNacosNamespace(String nacosNamespace){
		NACOS_NAMESPACE = nacosNamespace;
	}

	@Value("${nacos.gateway.route.config.data-id}")
	public void setNacosRouteDataId(String nacosRouteDataId){
		NACOS_ROUTE_DATA_ID = nacosRouteDataId;
	}

	@Value("${nacos.gateway.route.config.group}")
	public void setNacosRouteGroupId(String group){
		NACOS_ROUTE_GROUP = group;
	}


}
